package com.diqye.controller.intercepter;

import java.lang.reflect.Method;
import java.util.ArrayList;

import com.diqye.controller.util.CKit;
import com.diqye.engine.Controller;
import com.diqye.engine.interceptor.Interceptor;

public class ValidateLogin extends Interceptor {
	ArrayList actions = new ArrayList();
	public ValidateLogin(){
		actions.add("User_save");
		actions.add("User_deleteTag");
		actions.add("User_delete");
		actions.add("User_modify");
		actions.add("Blog_save");
	}
	@Override
	public boolean validateAction(String reqAction) {
		return actions.contains(reqAction)||reqAction.endsWith("Li");
	}

	@Override
	protected void intercept(String action, Controller controller,
			Method method, Interceptor last) throws Exception {
		if(CKit.getLogin(controller.getRequest())==null){
			controller.renderErr("你未登录，或者会话已过期");
		}else{
			next.intercept(action, controller, method);
		}
		
	}

}
